<style>
    .import {
        opacity: 0;
        position: absolute;
        width: 69px;
        height: 38px;
        margin-left: -10px;
    }
</style>
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <!-- 头部操作栏 -->
            <div class="layui-form lay-header" name="saleWorkOrderProcessingForm">
                <div class="toolbar">
                    <div class="layui-form-item lay-query-content">
                        <div class="lay-query-box">
                            <div class="query-lt">
                                <div class="layui-inline">
                                    <label class="layui-form-label">产品名称：</label>
                                    <div class="layui-input-inline">
                                        <input name="skuName" class="layui-input" type="text" placeholder="产品名称" autocomplete="off"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">产品编码：</label>
                                    <div class="layui-input-inline">
                                        <input name="skuCode" class="layui-input" type="text" placeholder="产品编码" autocomplete="off"/>
                                    </div>
                                </div>
                            </div>
                            <div class="query-rt">
                                <div class="layui-inline">
                                    <button class="layui-btn icon-btn" lay-filter="formSubSearchLog" lay-submit layui-form-keyDownSearch="true"
                                            type="button">查询
                                    </button>
                                    <button class="layui-btn icon-btn color-white" lay-filter="resets" lay-submit>重置
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="lay-btn-rows">
                    <div class="lay-btn-box">
                        <div class="lay-btn-lt">
                            <a id="productBtnAdd" class="layui-btn icon-btn color-reseda">添加产品/物资信息</a>
                            <button id="productDetailBtnImport" class="layui-btn icon-btn color-reseda">
                                <input id="uploaderInput" type="file" name="file" class="import" accept=".xls,.xlsx"/>导入
                            </button>
                        </div>
                        <div class="lay-btn-rt">
                            <button id="productDetailBtnTemplate" class="layui-btn icon-btn color-green">模板下载</button>
                        </div>
                    </div>
                </div>
            </div>
            <!-- 表格 -->
            <table class="layui-table img-table" id="productDetailTable" lay-filter="productDetailTable"></table>
        </div>
    </div>
</div>

<style>
    form[lay-filter="productAddForm"] .tdInputOne > input {
        display: inline-block;
        width: 30%;
    }

    form[lay-filter="productAddForm"] .tdSelectOne > .layui-form-select {
        width: 19%;
        display: inline-block;
        margin-bottom: 5px;
        margin-right: 5px;
    }

    form[lay-filter="productAddForm"] .inputBorderNone {
        border-color: transparent;
        outline-color: transparent;
    }

    form[lay-filter="productAddForm"] .inputBorderNone:hover {
        border-color: transparent !important;
        outline-color: transparent;
    }

    form[lay-filter="productAddForm"] .inputBorderNone:focus {
        border-color: transparent !important;
        outline-color: transparent;
    }
    div[lay-id='productDetailTable'] .layui-table-body .layui-table-cell{
        height: 79px;
        line-height: 79px;
    }
    .layui-form-label.w-120{
        width: 120px;
    }
</style>


<!-- 表格操作列 -->
<script type="text/html" id="productDetailTableBar">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">详情</a>
<!--    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="syncSku">同步到云端</a>-->
</script>

<!-- 表单弹窗 -->
<script type="text/html" id="productDetailForm">
    <form lay-filter="productDetailForm" class="layui-form model-form">
        <input name="id" type="hidden"/>
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">产品图片</label>
                <div class="layui-input-inline">
                    <input type="hidden" name="pic" id="pic" value=""/>
                    <img src="" style="height: 80px;width: 80px" id="picImg"/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">产品系列名称</label>
                <div class="layui-input-inline">
                    <input name="productName" id="productName" class="layui-input borderNone"
                           type="text" disabled/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">类型名称</label>
                <div class="layui-input-inline">
                    <input name="productType" id="productType" class="layui-input borderNone"
                           type="text" disabled/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">分类名称</label>
                <div class="layui-input-inline">
                    <input name="categoryName" id="categoryName" class="layui-input borderNone"
                           type="text" disabled/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">包装单位</label>
                <div class="layui-input-inline">
                    <input name="unitName" id="unitName" class="layui-input borderNone"
                           type="text" disabled/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">包装方案</label>
                <div class="layui-input-inline">
                    <input name="packName" id="packName" class="layui-input borderNone"
                           type="text" disabled/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">计价方式</label>
                <div class="layui-input-inline">
                    <input name="pricingMethod" id="pricingMethod" class="layui-input borderNone"
                           type="text" disabled/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">计量方式</label>
                <div class="layui-input-inline">
                    <input name="inventoryUnitType" id="inventoryUnitType" class="layui-input borderNone"
                           type="text" disabled/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">品牌</label>
                <div class="layui-input-inline">
                    <input name="brandName" id="brandName" class="layui-input borderNone"
                           type="text" disabled/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">关键词</label>
                <div class="layui-input-inline">
                    <input name="keyword" id="keyword" class="layui-input borderNone"
                           type="text" disabled/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">卖点描述</label>
                <div class="layui-input-inline">
                    <input name="sellingPointSpec" id="sellingPointSpec" class="layui-input borderNone"
                           type="text" disabled/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">产品编号</label>
                <div class="layui-input-inline">
                    <input name="skuCode" id="skuCode" class="layui-input borderNone"
                           type="text" disabled/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">产品名称</label>
                <div class="layui-input-inline">
                    <input name="skuName" id="skuName" class="layui-input borderNone"
                           type="text" disabled/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">旧料号</label>
                <div class="layui-input-inline">
                    <input name="oldSkuCode" id="oldSkuCode" class="layui-input borderNone"
                           type="text" disabled/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">旧规格码</label>
                <div class="layui-input-inline">
                    <input name="oldSpecCode" id="oldSpecCode" class="layui-input borderNone"
                           type="text" disabled/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">标准规格码参数</label>
                <div class="layui-input-inline">
                    <input name="skuSpecValue" id="skuSpecValueNew" class="layui-input borderNone"
                           type="text" disabled/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">标准规格码</label>
                <div class="layui-input-inline">
                    <input name="skuSpecValueNames" id="skuSpecValueNames" class="layui-input borderNone"
                           type="text" disabled/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">单位成本价</label>
                <div class="layui-input-inline">
                    <input name="costPrice" id="costPrice" class="layui-input borderNone"
                           type="text" disabled/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">市场指导价</label>
                <div class="layui-input-inline">
                    <input name="marketPrice" id="marketPrice" class="layui-input borderNone"
                           type="text" disabled/>
                </div>
            </div>
        </div>
        <!--<div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">企业产品系列图片</label>
                <div class="layui-input-inline">
                    <input type="hidden" name="enterpriseItemPic" id="enterpriseItemPic" value=""/>
                    <img src="" style="height: 80px;width: 80px" id="enterpriseItemPicImg"/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">企业产品图片</label>
                <div class="layui-input-inline">
                    <input type="hidden" name="enterpriseProductDetailPic" id="enterpriseProductDetailPic" value=""/>
                    <img src="" style="height: 80px;width: 80px" id="enterpriseProductDetailPicImg"/>
                </div>
            </div>

        </div>
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">企业产品系列名称</label>
                <div class="layui-input-inline">
                    <input name="enterpriseName" id="enterpriseName" class="layui-input borderNone"
                           type="text" disabled/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">企业产品编码</label>
                <div class="layui-input-inline">
                    <input name="enterpriseProductCode" id="enterpriseProductCode"
                           class="layui-input borderNone" type="text" disabled/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">企业产品类型</label>
                <div class="layui-input-inline">
                    <input name="enterpriseProductType" id="enterpriseProductType"
                           class="layui-input borderNone" type="text" disabled/>
                </div>
            </div>
        </div>
       &lt;!&ndash; <div class="layui-form-item">
            <label class="layui-form-label w-120">企业产品扩展分类</label>
            <div class="layui-input-inline">
                <input name="enterpriseProductCategoryExt" id="enterpriseProductCategoryExt"
                       class="layui-input borderNone" type="text" disabled/>
            </div>
        </div>&ndash;&gt;
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">企业产品分类</label>
                <div class="layui-input-inline">
                    <input name="enterpriseProductCategory" id="enterpriseProductCategory"
                           class="layui-input borderNone" type="text" disabled/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">企业产品名称</label>
                <div class="layui-input-inline">
                    <input name="enterpriseDetailName" id="enterpriseDetailName" class="layui-input borderNone"
                           type="text" disabled/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">企业产品编码</label>
                <div class="layui-input-inline">
                    <input name="enterpriseProductDetailCode" id="enterpriseProductDetailCode"
                           class="layui-input borderNone" type="text" disabled/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">企业品牌</label>
                <div class="layui-input-inline">
                    <input name="enterpriseProductDetailBrand" id="enterpriseProductDetailBrand"
                           class="layui-input borderNone" type="text" disabled/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">企业产品单位</label>
                <div class="layui-input-inline">
                    <input name="enterpriseProductDetailUnit" id="enterpriseProductDetailUnit"
                           class="layui-input borderNone" type="text" disabled/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">企业产品规格码</label>
                <div class="layui-input-inline">
                    <input name="enterpriseSkuSpecValueNames" id="enterpriseSkuSpecValueNames"
                           class="layui-input borderNone" type="text" disabled/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">企业产品旧规格码</label>
                <div class="layui-input-inline">
                    <input name="enterpriseOldSpecCode" id="enterpriseOldSpecCode"
                           class="layui-input borderNone" type="text" disabled/>
                </div>
            </div>
        </div>-->
        <div class="layui-form-item text-right">
            <div class="right-btn">
                <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            </div>
        </div>
    </form>
</script>

<!--添加产品-->
<script type="text/html" id="productAddForm">
    <form lay-filter="productAddForm" class="layui-form model-form"
          style="padding: 25px 20px 0;height: calc(100% - 25px);overflow: hidden;">
        <div class="open-details-box" style="height: calc(100% - 65px); overflow-y: scroll;">
            <div class="layui-form-item" style="margin-bottom: 50px">
                <table class="layui-table">
                    <thead>
                    <tr>
                        <th>选择产品系列</th>
                        <th>选择类型</th>
                        <th>选择分类</th>
                        <th>物资来源</th>
                        <th>包装单位</th>
                        <th>包装方案</th>
                        <th>计价方式</th>
                        <th>计量方式</th>
                        <th>所属品牌</th>
                        <th>关键词</th>
                        <th>卖点描述</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td>
                            <input name="productName" class="layui-input" type="text" placeholder="选择产品系列" readonly
                                   lay-verify="required" id="productNameInput" style="cursor: pointer"/>
                            <input name="productId" type="hidden"/>
                        </td>
                        <td>
                            <input name="productTypeName" class="layui-input inputBorderNone" type="text" readonly
                                   placeholder="选择类型"/>
                            <input name="productTypeId" type="hidden"/>
                        </td>
                        <td>
                            <input name="categoryName" class="layui-input inputBorderNone" type="text" readonly
                                   placeholder="选择分类"/>
                            <input name="productCategoryId" type="hidden"/>
                        </td>
                        <td>
                            <select name="productSource">
                                <option value="psi">进销存产品</option>
                                <!--  <option value="1">云仓产品</option>-->
                            </select>
                        </td>
                        <td>
                            <select name="unitId" lay-filter="getUnit" lay-verify="required"></select>
                        </td>
                        <td>
                            <select name="packId" lay-verify="required"></select>
                        </td>
                        <td>
                            <select name="pricingMethod" lay-verify="required">
                                <option value="piece">按件</option>
                                <option value="weight">按重量</option>
                            </select>
                        </td>
                        <td>
                            <select name="inventoryUnitType" lay-verify="required">
                                <option value="quantity">数量</option>
                                <option value="weight">重量</option>
                            </select>
                        </td>
                        <td>
                            <select name="brandId" lay-search></select>
                        </td>
                        <td>
                            <input name="keyword" class="layui-input" type="text" placeholder="逗号隔开" autocomplete="off"/>
                        </td>
                        <td>
                            <input name="sellingPointSpec" class="layui-input" type="text" placeholder="" autocomplete="off"/>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <div class="layui-form-item" style="margin-bottom: 50px">
                <table class="layui-table">
                    <colgroup>
                        <col width="150">
                        <col width="150">
                        <col width="150">
                        <col width="150">
                        <col>
                        <col width="150">
                    </colgroup>
                    <thead>
                    <tr>
                        <th>产品图片</th>
                        <th>产品编号</th>
                        <th>产品名称</th>
                        <th>旧料号</th>
                        <th>包装外观尺寸</th>
                        <th>重量</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td>
                            <input name="productPic" type="hidden" id="productPic" />
                            <div id="productPicPath" class="uploadImgStyle"></div>
                            <div id="productPicBtn" class="layui-btn layui-btn-xs" style="float: left; margin-top:5px">
                                上传图片
                            </div>
                        </td>
                        <td>
                            <!--<input name="skuCode" class="layui-input inputBorderNone" type="text" readonly/>-->
                            <input name="skuCode" class="layui-input" type="text" lay-verify="required" autocomplete="off"/>
                        </td>
                        <td>
                            <input name="skuName" class="layui-input" type="text" lay-verify="required" autocomplete="off"/>
                        </td>
                        <td>
                            <input name="oldSkuCode" class="layui-input" type="text" autocomplete="off"/>
                        </td>
                        <td class="tdInputOne">
                            <input name="exteriorSize" class="layui-input" type="text" placeholder="长度mm" autocomplete="off"/>*
                            <input name="exteriorSize1" class="layui-input" type="text" placeholder="高度mm" autocomplete="off"/>*
                            <input name="exteriorSize2" class="layui-input" type="text" placeholder="宽度mm" autocomplete="off"/>
                        </td>
                        <td>
                            <input name="maxBearing" class="layui-input" type="text" placeholder="单位(g)" autocomplete="off"/>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <div class="layui-form-item" style="margin-bottom: 50px">
                <table class="layui-table">
                    <colgroup>
                        <col width="150">
                        <col>
                        <col width="250">
                        <col width="150">
                        <col width="150">
                        <col>
                    </colgroup>
                    <thead>
                    <tr>
                        <th>旧规格码</th>
                        <th>标准规格码参数</th>
                        <th>标准规格码</th>
                        <th>单位成本价</th>
                        <th>市场指导价</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td><input name="oldSpecCode" class="layui-input" type="text" autocomplete="off"/></td>
                        <td class="tdSelectOne" id="skuSpecValue"></td>
                        <td><input name="skuSpecValueNames" class="layui-input" type="text" autocomplete="off"/></td>
                        <td><input name="costPrice" class="layui-input" type="text" lay-verify="decimal" autocomplete="off"/></td>
                        <td><input name="marketPrice" class="layui-input" type="text" lay-verify="decimal" autocomplete="off"/></td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn" type="button" lay-filter='productAddSubmit' lay-submit>提交</button>
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        </div>
    </form>
</script>

<!--产品系列列表-->
<script type="text/html" id="productRangeList">
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 头部操作栏 -->
                <form class="layui-form toolbar" lay-filter="productRangeList">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">系列名称：</label>
                            <div class="layui-input-inline">
                                <input name="name" class="layui-input" type="text"/>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn icon-btn" lay-filter="productRangeListSearchLog" lay-submit
                                    type="button">搜索
                            </button>
                            <button id="productRangeListAddClose" class="layui-btn icon-btn" type="button">确认选择</button>
                        </div>
                    </div>
                </form>

                <!-- 表格 -->
                <table class="layui-table" id="productRangeListTable" lay-filter="productRangeListTable"></table>


                <!--<div class="layui-form-item text-right">
                    <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
                    <button class="layui-btn" lay-filter="productFormSubmit" lay-submit>保存</button>
                </div>-->
            </div>
        </div>
    </div>
</script>
<!-- 数据同步到云端表单弹窗 -->
<script type="text/html" id="syncSkuForm">
    <form lay-filter="synsSkuForm" class="layui-form model-form formBg" style="padding:20px;">
        <div class="layui-card-body">
            <input type="hidden" name="enterpriseCode" id="enterpriseCode" value="">
            <div class="layui-row">
                <div class="layui-col-md4 conentStyle">
                    <div class="conentBg">
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">企业产品系列图片:</label>
                            <div class="layui-input-inline">
                                <input type="hidden" name="enterpriseItemPic" id="enterpriseItemPic" value=""/>
                                <img src="" style="height: 135px;width: 135px" id="enterpriseItemPicImg"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">企业产品系列名称:</label>
                            <div class="layui-input-inline">
                                <input name="enterpriseName" id="enterpriseName" class="layui-input borderNone"
                                       type="text" disabled/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">企业产品编码</label>
                            <div class="layui-input-inline">
                                <input name="enterpriseProductCode" id="enterpriseProductCode"
                                       class="layui-input borderNone" type="text" disabled/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">企业产品类型</label>
                            <div class="layui-input-inline">
                                <input name="enterpriseProductType" id="enterpriseProductType"
                                       class="layui-input borderNone" type="text" disabled/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">企业产品分类</label>
                            <div class="layui-input-inline">
                                <input name="enterpriseProductCategory" id="enterpriseProductCategory"
                                       class="layui-input borderNone" type="text" disabled/>
                            </div>
                        </div>
                        <!--<div class="layui-form-item">
                            <label class="layui-form-label w-120">企业产品扩展分类</label>
                            <div class="layui-input-inline">
                                <input name="enterpriseProductCategoryExt" id="enterpriseProductCategoryExt"
                                       class="layui-input borderNone" type="text" disabled/>
                            </div>
                        </div>-->
                    </div>
                </div>
                <div class="layui-col-md8 conentStyle">
                    <div class="conentBg">
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">平台产品系列图片:</label>
                            <div class="layui-input-inline">
                                <input type="hidden" name="pictureSynsInput" id="pictureSynsInput" value=""/>
                                <img src="" style="height: 135px;width: 135px" id="pictureSyns"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">平台产品系列名称</label>
                            <div class="layui-input-inline">
                                <input id="platformName" placeholder="请输入平台产品系列" name="platformName" class="layui-input" lay-search lay-verify="required"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">平台产品编码</label>
                            <div class="layui-input-inline">
                                <input name="platformProductCode" id="platformProductCode" class="layui-input"
                                       type="text" placeholder="请输入平台产品系列" disabled/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">平台产品类型</label>
                            <div class="layui-input-inline">
                                <input id="platformProductTypeId" type="hidden">
                                <select name="platformProductType" id="platformProductType" class="layui-input"
                                       type="text">
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">平台产品分类</label>
                            <div class="layui-input-inline">
                                <select name="platformProductCategory" id="platformProductCategory" class="layui-input"
                                        type="text">
                                </select>
                            </div>
                        </div>
                       <!-- <div class="layui-form-item">
                            <label class="layui-form-label w-120">平台产品扩展分类</label>
                            <div class="layui-input-inline">
                            <input name="platformProductCategoryExt" id="platformProductCategoryExt" class="layui-input"
                                   type="text" disabled/>
                            </div>
                        </div>-->
                        <!--<div class="layui-form-item">
                            <label class="layui-form-label w-120">平台产品属性</label>
                            <div class="layui-input-block">
                                <div class="layui-input-inline mr0" id="platformProductAttrHtml"
                                     name="platformProductAttrHtml"></div>
                                <div id="platformProductAttrValueHtml" name="platformProductAttrValueHtml"></div>
                            </div>
                        </div>-->
                    </div>
                </div>
            </div>

            <div class="layui-card-body">
                <input type="hidden" name="enterpriseCode" id="enterpriseDetailCode" value="">
                <div class="layui-row">
                    <div class="layui-col-md4 conentStyle">
                        <div class="conentBg">
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品图片:</label>
                                <div class="layui-input-inline">
                                    <input type="hidden" name="enterpriseProductDetailPic" id="enterpriseProductDetailPic" value=""/>
                                    <img src="" style="height: 80px;width: 80px" id="enterpriseProductDetailPicImg"/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品名称:</label>
                                <div class="layui-input-inline">
                                    <input name="enterpriseDetailName" id="enterpriseDetailName" class="layui-input borderNone"
                                           type="text" disabled/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品编码</label>
                                <div class="layui-input-inline">
                                    <input name="enterpriseProductDetailCode" id="enterpriseProductDetailCode"
                                           class="layui-input borderNone" type="text" disabled/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业品牌</label>
                                <div class="layui-input-inline">
                                    <input name="enterpriseProductDetailBrand" id="enterpriseProductDetailBrand"
                                           class="layui-input borderNone" type="text" disabled/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品单位</label>
                                <div class="layui-input-inline">
                                    <input name="enterpriseProductDetailUnit" id="enterpriseProductDetailUnit"
                                           class="layui-input borderNone" type="text" disabled/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品规格码</label>
                                <div class="layui-input-inline">
                                    <input name="enterpriseSkuSpecValueNames" id="enterpriseSkuSpecValueNames"
                                           class="layui-input borderNone" type="text" disabled/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品旧规格码</label>
                                <div class="layui-input-inline">
                                    <input name="enterpriseOldSpecCode" id="enterpriseOldSpecCode"
                                           class="layui-input borderNone" type="text" disabled/>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md8 conentStyle">
                        <div class="conentBg">
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">平台产品图片:</label>
                                <div class="layui-input-inline">
                                    <input type="hidden" name="platformProductDetailPic" id="platformProductDetailPic" value=""/>
                                    <img src="" style="height: 80px;width: 80px" id="platformItemPicImg"/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">平台产品名称</label>
                                <div class="layui-input-inline">
                                    <input name="platformDetailName" id="platformDetailName" class="layui-input" type="text"
                                           placeholder="请输入产品名称"/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">平台产品编码</label>
                                <div class="layui-input-inline">
                                    <input name="platformProductDetailCode" id="platformProductDetailCode" class="layui-input"
                                           type="text" placeholder="请输入产品编码" disabled/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">平台品牌</label>
                                <div class="layui-input-inline">
                                    <select name="platformProductDetailBrand" id="platformProductDetailBrand" class="layui-input"
                                            type="text">
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品单位</label>
                                <div class="layui-input-inline">
                                    <select name="platformProductDetailUnit" id="platformProductDetailUnit" class="layui-input"
                                            type="text">
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品规格码</label>
                                <div class="layui-input-inline">
                                    <input name="platformSkuSpecValueNames" id="platformSkuSpecValueNames"
                                           class="layui-input borderNone" type="text" />
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品旧规格码</label>
                                <div class="layui-input-inline">
                                    <input name="platformOldSpecCode" id="platformOldSpecCode"
                                           class="layui-input borderNone" type="text" />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item text-right">
                    <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
                    <button class="layui-btn" lay-filter="syncSubmit" lay-submit>同步</button>
                </div>
        </div>
        </div>
    </form>
</script>
<!-- 产品系列弹窗 -->
<script type="text/html" id="productForm">
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 头部操作栏 -->
                <div class="layui-form lay-header">
                    <div class="toolbar">
                        <div class="layui-form-item lay-query-content">
                            <div class="lay-query-box">
                                <div class="query-lt">
                                    <div class="layui-inline">
                                        <label class="layui-form-label w-auto">产品编号：</label>
                                        <div class="layui-input-inline">
                                            <input name="productCode" class="layui-input" type="text" placeholder="请输入产品编号"/>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label w-auto">产品名称：</label>
                                        <div class="layui-input-inline">
                                            <input name="name" class="layui-input" type="text" placeholder="请产品名称"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="query-rt">
                                    <div class="layui-inline">
                                        <button class="layui-btn icon-btn color-green" lay-filter="formSubSearchLog" lay-submit>查询</button>
                                        <button class="layui-btn icon-btn color-white" lay-filter="resets" lay-submit>重置</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="lay-btn-rows">
                        <div class="lay-btn-box">
                            <div class="lay-btn-lt">
                            </div>
                            <div class="lay-btn-rt">
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 表格 -->
                <table class="layui-table" id="productTable" lay-filter="productTable"></table>

                <div class="layui-form-item text-right">
                    <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
                    <button class="layui-btn" lay-filter="productSubmit" lay-submit>提交</button>
                </div>
            </div>
        </div>
    </div>
</script>
<!-- js部分 -->
<script>
    layui.use(['layer', 'form', 'table', 'admin', 'upload'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var config = layui.config;
        var admin = layui.admin;
        var upload = layui.upload;
        var syncProductName = "";
        var syncProductId = 0;

        form.render("select");
        // 渲染表格
        var insTb = table.render({
            elem: '#productDetailTable',
            url: config.base + 'enterprise/product/admin/productDetailWMS/list',
            where: {categoryType: 'production'},
            toolbar: true,
            defaultToolbar: ["filter"],
            page: true,
            limit: 5,
            limits:[5,10,20,30,40,50,60,70,80],
            cellMinWidth: 100,
            cols: [[
                {type: 'numbers',title: '序号', fixed: 'left'}
                , {field: 'productPic', fixed: 'left', width: 110, title: '图片',templet:function (d) {
                        if(d.productPic){
                            return '<img src="'+ d.productPic +'"/>';
                        }
                        return '<img src="assets/images/default-icon.png"/>';
                    }}
                , {field: 'skuName', sort: true, title: '产品名称', fixed: 'left'}
                , {field: 'skuCode', sort: true, title: '产品编号'}
                , {field: 'skuSpecValueNames', sort: true, title: '规格码', width: 160}
                , {field: 'brandName', sort: false, title: '品牌'}
                , {field: 'productName', sort: true, title: '所属产品系列', width: 120}
                , {field: 'productType', sort: true, title: '产品类型'}
                , {field: 'productCategory', sort: true, title: '产品分类'}
                , {field: 'unitName', sort: true, title: '单位'}
                , {field: 'productSourceDesc', sort: true, title: '物资来源'}
                , {field: 'createTime', sort: true, title: '添加时间'}
                , {align: 'center', toolbar: '#productDetailTableBar', title: '操作', width: 100, fixed: 'right'}
            ]],
        });

        // 工具条点击事件
        table.on('tool(productDetailTable)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') { //修改
                showEditModel(data);
            } else if (obj.event === 'del') { // 删除
                doDelete(obj);
            }else if (obj.event === 'syncSku') { // 同步
                syncSku(obj);
            }
        });

        //监听排序
        table.on('sort(productDetailTable)', function (obj) {
            table.reload('productDetailTable', {
                initSort: obj
                , where: {
                    sort: obj.field
                    , order: obj.type
                }
            });
        });

        // 搜索
        form.on('submit(formSubSearchLog)', function (data) {
            insTb.reload({where: data.field, page: {curr: 1}}, 'data');
        });

        // 重置搜索
        form.on('submit(resets)', function (data) {
            $(".lay-header").find('select').val("");
            $(".lay-header").find('input').val("");
            let field = data.field;
            for (let key in field) {
                field[key] = ''
            }
            insTb.reload({where: field, page: {curr: 1}}, 'data');
        });

        // 添加按钮点击事件
        $('#productDetailBtnAdd').click(function () {
            showEditModel();
        });

        // 显示编辑弹窗
        function showEditModel(data) {
            admin.open({
                type: 1,
                area: '1200px',
                offset: '65px',
                title: '产品明细表',
                content: $('#productDetailForm').html(),
                success: function () {
                    //获取企业产品
                    admin.reqSync('enterprise/product/admin/productDetailWMS/syncList?skuCode='+data.skuCode, {}, function (res) {
                        layer.closeAll('loading');
                        if (res.code == 200) {
                            $("#picImg").attr("src",res.data.productDetail.productPic)
                            $("#productName").val(res.data.name)
                            $("#productType").val(res.data.productDetail.productTypeName)
                            $("#categoryName").val(res.data.productDetail.categoryName)
                            $("#unitName").val(res.data.productDetail.unitName)
                            $("#packName").val(res.data.productDetail.packName)
                            $("#pricingMethod").val(res.data.productDetail.pricingMethodDesc)
                            $("#inventoryUnitType").val(res.data.productDetail.inventoryUnitTypeDesc)
                            $("#brandName").val(res.data.productDetail.brandName)
                            $("#keyword").val(res.data.keyword)
                            $("#sellingPointSpec").val(res.data.sellingPointSpec)
                            $("#skuCode").val(res.data.productDetail.skuCode)
                            $("#skuName").val(res.data.productDetail.skuName)
                            $("#oldSkuCode").val(res.data.productDetail.oldSkuCode)
                            $("#oldSpecCode").val(res.data.productDetail.oldSpecCode)
                            $("#skuSpecValueNew").val(res.data.productDetail.skuSpecValue)
                            $("#skuSpecValueNames").val(res.data.productDetail.skuSpecValueNames)
                            $("#costPrice").val(res.data.productDetail.costPrice)
                            $("#marketPrice").val(res.data.productDetail.marketPrice)
                            /*$("#enterpriseItemPicImg").attr("src", res.data.picture);
                            $("#enterpriseName").val(res.data.name)
                            $("#enterpriseProductCode").val(res.data.productCode)
                            $("#enterpriseProductType").val(res.data.productType)
                            $("#enterpriseProductCategory").val(res.data.productCategory)
                            $("#enterpriseProductCategoryExt").val(res.data.enterpriseProductCategoryExt)
                            $("#enterpriseDetailName").val(res.data.productDetail.productName)
                            $("#enterpriseProductDetailPicImg").attr("src",res.data.productDetail.productPic)
                            $("#enterpriseProductDetailCode").val(res.data.productDetail.skuCode)
                            $("#enterpriseProductDetailBrand").val(res.data.productDetail.brandName)
                            $("#enterpriseProductDetailUnit").val(res.data.productDetail.unitName)
                            $("#enterpriseSkuSpecValueNames").val(res.data.productDetail.skuSpecValueNames)
                            $("#enterpriseOldSpecCode").val(res.data.productDetail.oldSpecCode)*/
                            //form.render();
                        } else {
                            layer.msg(res.msg, {icon: 2});
                        }
                    }, 'GET');
                }
            });
        }
        //查询企业信息
        var enterpriseInfo;
        admin.req('enterprise/system/admin/enterpricceId/getEnterpricceIdVO', {}, function (res) {
            enterpriseInfo = res.data;
        }, 'get', false);
        function syncSku(obj) {
            admin.open({
                type: 1,
                area: ['80%', '80%'],
                offset: '65px',
                title: '同步至云端',
                content: $('#syncSkuForm').html(),
                success: function () {
                    var sync = false;
                    var productData = null;
                    //获取企业产品
                    admin.reqSync('enterprise/product/admin/productDetailWMS/syncList?skuCode='+obj.data.skuCode, {}, function (res) {
                        layer.closeAll('loading');
                        if (res.code == 200) {
                            $("#enterpriseItemPicImg").attr("src", res.data.picture);
                            $("#enterpriseName").val(res.data.name)
                            $("#enterpriseProductCode").val(res.data.productCode)
                            $("#enterpriseProductType").val(res.data.productType)
                            $("#enterpriseProductCategory").val(res.data.productCategory)
                            $("#enterpriseProductCategoryExt").val(res.data.enterpriseProductCategoryExt)
                            $("#enterpriseDetailName").val(res.data.productDetail.productName)
                            $("#enterpriseProductDetailPicImg").attr("src",res.data.productDetail.productPic)
                            $("#enterpriseProductDetailCode").val(res.data.productDetail.skuCode)
                            $("#enterpriseProductDetailBrand").val(res.data.productDetail.brandName)
                            $("#enterpriseProductDetailUnit").val(res.data.productDetail.unitName)
                            $("#enterpriseSkuSpecValueNames").val(res.data.productDetail.skuSpecValueNames)
                            $("#enterpriseOldSpecCode").val(res.data.productDetail.oldSpecCode)


                            $("#pictureSyns").attr("src", res.data.picture);
                            $("#platformProductCode").val(enterpriseInfo.enterpriseCode+"_"+res.data.productCode)
                            $("#platformName").val(res.data.name)
                            $("#platformItemPicImg").attr("src",res.data.productDetail.productPic)
                            $("#platformProductDetailCode").val(enterpriseInfo.enterpriseCode+"_"+res.data.productDetail.skuCode)
                            $("#platformDetailName").val(res.data.productDetail.productName)
                            $("#platformSkuSpecValueNames").val(res.data.productDetail.skuSpecValueNames)
                            $("#platformOldSpecCode").val(res.data.productDetail.oldSpecCode)
                            productData = res.data
                            //form.render();
                        } else {
                            layer.msg(res.msg, {icon: 2});
                        }
                    }, 'GET');
                    /*//获取平台产品
                    $("#platformName").click(function () {
                       var platformForm = admin.open({
                            type: 1,
                            area: ['80%', '80%'],
                            offset: '65px',
                            title: '同步至云端',
                            content: $('#productForm').html(),
                            success: function () {
                                // 渲染表格
                                var insTb = table.render({
                                    elem: '#productTable',
                                    url: config.base + 'enterprise/product/admin/productSeries/platformProductSeries',
                                    page: true,
                                    where: {
                                        "dataSourceType": 0,
                                        "type": 0
                                    },
                                    cellMinWidth: 100,
                                    cols: [[
                                        {type: 'radio'}
                                        , {
                                            field: 'picture', sort: true, title: '产品图片'
                                            , templet: '<div><img src="{{ d.picture}}"></div>'
                                        }
                                        , {field: 'name', sort: true, title: '产品名称'}
                                        , {field: 'productCode', sort: true, title: '产品编码'}
                                        , {field: 'productTypeName', sort: true, title: '产品类型'}
                                        , {field: 'productCategoryName', sort: true, title: '产品分类'}
                                        , {field: 'keyword', sort: true, title: '关键词'}
                                        , {field: 'pricingMethodDesc', sort: true, title: '计价方式'}
                                        , {field: 'unitName', sort: true, title: '单位'}
                                        , {field: 'createTime', sort: true, title: '创建时间'}
                                        , {field: 'creatorName', sort: true, title: '创建人'}
                                        , {field: 'isSynsDes', sort: true, title: '是否同步'}
                                        , {field: 'synsTime', sort: true, title: '同步时间'}
                                        , {align: 'center', toolbar: '#productTableBar', title: '操作', width: 300}
                                    ]],
                                    done: function (res, curr, count) {
                                        //移除按钮
                                        // var menuButton = config.getMenuButton(location.hash);
                                        // if (menuButton.indexOf("搜索") == -1) {
                                        //     $('.layui-form.toolbar').remove();
                                        // }
                                        // if (menuButton.indexOf("修改") == -1) {
                                        //     $("[lay-event='edit']").remove();
                                        // }
                                        // if (menuButton.indexOf("删除") == -1) {
                                        //     $("[lay-event='del']").remove();
                                        // }
                                    }
                                });
                                // 搜索
                                form.on('submit(formSubSearchLog)', function (data) {
                                    insTb.reload({where: data.field, page: {curr: 1}}, 'data');
                                });
                                form.on('submit(productSubmit)', function (data) {
                                    var selectData = layui.table.checkStatus('productTable').data;
                                    console.log(selectData)
                                    $("#platformName").val(selectData[0].name);
                                    $("#platformNameId").val(selectData[0].id);
                                    $("#platformProductCode").val(selectData[0].productCode);
                                    $("#platformProductType").val(selectData[0].productTypeName);
                                    $("#platformProductTypeId").val(selectData[0].productTypeId);
                                    $("#platformProductCategory").val(selectData[0].productCategoryName);
                                    $("#platformProductCategoryId").val(selectData[0].productCategoryId);
                                    layer.close(platformForm);
                                });

                            }
                        })
                    })*/

                    //获取平台产品类型
                    admin.req('enterprise/product/admin/productType/platformProductTypeList',{},function(res){
                        if (res.code === 200) {
                            loadSelectHtml(res.data, '平台产品类型', 'platformProductType', 1, 'synsSkuForm')
                        } else {
                            loadSelectHtml([], '平台产品类型', 'platformProductType', 1, 'synsSkuForm')
                        }
                    },'GET')

                    //获取平台产品分类
                    admin.req('enterprise/product/admin/productCategory/platformProductCategoryList',{},function(res){
                        if (res.code === 200) {
                            loadSelectHtml(res.data, '平台产品分类', 'platformProductCategory', 1, 'synsSkuForm')
                        } else {
                            loadSelectHtml([], '平台产品分类', 'platformProductCategory', 1, 'synsSkuForm')
                        }
                    },'GET')

                    //获取平台品牌
                    admin.req('enterprise/product/admin/productBrand/platformList',{},function(res){
                        if (res.code === 200) {
                            loadSelectHtml(res.data, '平台品牌', 'platformProductDetailBrand', 1, 'synsSkuForm')
                        } else {
                            loadSelectHtml([], '平台品牌', 'platformProductDetailBrand', 1, 'synsSkuForm')
                        }
                    },'GET')

                    //获取平台产品单位
                    admin.req('enterprise/product/admin/productUnit/platformProductUnitList',{},function(res){
                        if (res.code === 200) {
                            loadSelectHtml(res.data, '平台产品分类', 'platformProductDetailUnit', 1, 'synsSkuForm')
                        } else {
                            loadSelectHtml([], '平台产品分类', 'platformProductDetailUnit', 1, 'synsSkuForm')
                        }
                    },'GET')

                        /* admin.req('enterprise/product/admin/productDetailWMS/syncPlatformList', JSON.stringify(productData)  , function (res) {
                             layer.closeAll('loading');
                             if (res.code == 200) {
                                 $("#pictureSyns").attr("src", res.data.picture);
                                 $("#platformName").val(res.data.name)
                                 $("#platformProductCode").val(res.data.productCode)
                                 $("#platformProductType").val(res.data.productType)
                                 $("#platformProductCategory").val(res.data.productCategory)
                                 $("#platformProductCategoryExt").val(res.data.enterpriseProductCategoryExt)
                                 $("#platformDetailName").val(res.data.productDetail.productName)
                                 $("#platformItemPicImg").attr("src",res.data.productDetail.productPic)
                                 $("#platformProductDetailCode").val(res.data.productDetail.skuCode)
                                 $("#platformProductDetailBrand").val(res.data.productDetail.brandName)
                                 $("#platformProductDetailUnit").val(res.data.productDetail.unitName)
                                 sync = true;
                                 //form.render();
                             } else {
                                 layer.msg(res.msg, {icon: 2});
                             }
                         }, 'POST',true, 'application/json; charset=utf-8');*/

                    form.on('submit(syncSubmit)', function (data) {
                        productData.picture = $("#pictureSyns").val();
                        productData.productCode = $("#platformProductCode").val()
                        productData.name = $("#platformName").val()
                        productData.productTypeId = $("#platformProductType").val()
                        productData.productCategoryId = $("#platformProductCategory").val()
                        productData.productDetail.productPic =$("#platformItemPicImg").val()
                        productData.productDetail.skuCode =$("#platformProductDetailCode").val()
                        productData.productDetail.skuName =$("#platformDetailName").val()
                        productData.productDetail.skuSpecValueNames =$("#platformSkuSpecValueNames").val()
                        productData.productDetail.oldSpecCode =$("#platformOldSpecCode").val()
                        productData.productDetail.brandId =$("#platformProductDetailBrand").val()
                        productData.productDetail.unitId =$("#platformProductDetailUnit").val()
                         admin.req('enterprise/product/admin/productDetailWMS/syncProduct' ,  JSON.stringify(productData), function (res) {
                                if (res.code == 200) {
                                    layer.msg(res.msg, {icon: 1});
                                } else {
                                    layer.msg(res.msg, {icon: 2});
                                }
                            }, 'POST',true, 'application/json; charset=utf-8');
                       /* layer.msg("不允许非法同步", {icon: 2});*/
                        return false
                    });
                }
            });
        }
        // 删除
        function doDelete(obj) {
            layer.confirm('确定要删除吗？', {
                offset: '65px',
                skin: 'layui-layer-admin'
            }, function (i) {
                layer.close(i);
                layer.load(2);
                admin.req('enterprise/product/admin/productDetail/' + obj.data.id, {}, function (res) {
                    layer.closeAll('loading');
                    if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1});
                        obj.del();
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }, 'DELETE');
            });
        }

        // 导出excel
        $('#productDetailBtnExport').click(function () {
            var checkRows = table.checkStatus('productDetailTable');
            if (checkRows.data.length == 0) {
                layer.msg('请选择要导出的数据', {icon: 2});
            } else {
                table.exportFile(insTb.config.id, checkRows.data, 'xls');
            }
        });

        // 添加产品/物资信息按钮点击事件
        $('#productBtnAdd').click(function () {
            showAddProduct()
        });

        //添加产品/物资信息弹窗
        function showAddProduct() {
            admin.open({
                type: 1,
                area: ['80%', '80%'],
                offset: '65px',
                title: '添加产品/物资信息',
                content: $('#productAddForm').html(),
                success: function () {
                    let productAddFormData = {};
                    form.render("select");

                    //自定义验证规则
                    form.verify({
                        decimal: [/^[0-9]*(\.[0-9]{1,2})?$/, '格式错误']
                    })

                    //请求品牌
                    admin.req('enterprise/product/admin/productBrand/list', {type: 0, page: 1, limit: 9999}, res => {
                        if (res.code === 200) {
                            loadSelectHtml(res.data, '请选择所属品牌', 'brandId', 1, 'productAddForm')
                        } else {
                            loadSelectHtml([], '请选择所属品牌', 'brandId', 1, 'productAddForm')
                        }
                    }, 'get');

                    // 查询包装单位
                    function getProductUnit(productType){
                        //请求包装单位
                        admin.req('enterprise/product/admin/productUnit/list', {type: 0, page: 1, limit: 9999, isBaseUnit: false, productType: productType}, res => {
                            if (res.code === 200) {
                                loadSelectHtml(res.data, '包装单位', 'unitId', 1, 'productAddForm')
                            } else {
                                loadSelectHtml([], '包装单位', 'unitId', 1, 'productAddForm')
                            }
                        }, 'get');
                    }

                    // 选择包装单位
                    form.on('select(getUnit)', function (d) {
                        if(d.value){
                            // 查询包装方案
                            admin.req('enterprise/product/admin/productPack/getByUnitId', {productUnitId: d.value}, function (res) {
                                if (res.code === 200) {
                                    let packList = []
                                    res.data.forEach(item => {
                                        if (item.isDeleted) {
                                            packList.push(item)
                                        }
                                    })
                                    loadSelectHtml(packList, "包装方案", "packId", 1, 'productAddForm');
                                } else {
                                    loadSelectHtml([], '包装方案', 'packId', 1, 'productAddForm')
                                }
                            }, 'get');
                        }else{
                            loadSelectHtml([], '包装方案', 'packId', 1, 'productAddForm')
                        }
                    })


                    $('#productPicBtn').click(uploadImg('productPicBtn', 'productPicPath', 'productPic'));

                    $('#productNameInput').click(function () {
                        let productRangeListIndex = admin.open({
                            type: 1,
                            area: ['70%', '75%'],
                            offset: '75px',
                            title: '选择产品系列列表',
                            content: $('#productRangeList').html(),
                            success: function () {
                                let productRangeListTb = table.render({
                                    elem: '#productRangeListTable',
                                    url: config.base + 'enterprise/product/admin/product/list',
                                    where: {categoryType: 'production'},
                                    page: true,
                                    cellMinWidth: 100,
                                    cols: [[
                                        {type: 'radio'}
                                        , {field: 'name', title: '系列名称'}
                                        , {field: 'productCode', title: '产品编码'}
                                        , {field: 'productTypeName', title: '类型名称'}
                                        , {field: 'productCategoryName', title: '分类名称'}
                                    ]],
                                    done: function (res, curr, count) {
                                    }
                                });

                                form.on('submit(productRangeListSearchLog)', function (data) {
                                    productRangeListTb.reload({where: data.field,page: {curr: 1}},'data');
                                });

                                $('#productRangeListAddClose').click(function () {
                                    let checkStatus = table.checkStatus('productRangeListTable');
                                    if (checkStatus.data.length == 0) {
                                        layer.msg('请选择数据', {icon: 5});
                                    } else {
                                        //请求流水号
                                        admin.reqSync('enterprise/product/admin/productDetailWMS/serialNumber', {productCode: checkStatus.data[0].productCode}, res => {
                                            if (res.code === 200) {
                                                productAddFormData.skuCode = res.msg;
                                            } else {
                                                productAddFormData.skuCode = checkStatus.data[0].productCode;
                                            }
                                        }, 'get');

                                        // productAddFormData.skuCode = checkStatus.data[0].productCode;
                                        productAddFormData.productId = checkStatus.data[0].id;
                                        productAddFormData.productName = checkStatus.data[0].name;
                                        productAddFormData.productTypeName = checkStatus.data[0].productTypeName;
                                        productAddFormData.productTypeId = checkStatus.data[0].productTypeId;
                                        productAddFormData.categoryName = checkStatus.data[0].productCategoryName;
                                        productAddFormData.productCategoryId = checkStatus.data[0].productCategoryId;
                                        form.val('productAddForm', productAddFormData);
                                        getSkuSpecValue(productAddFormData.productTypeId);
                                        getProductUnit(productAddFormData.productTypeId)
                                        layer.close(productRangeListIndex);
                                    }
                                })
                            }
                        });
                    });

                    /*请求规格参数*/
                    function getSkuSpecValue(_productTypeId) {
                        admin.req('enterprise/product/admin/productSpec/getProductSpecByProductTypeId', {productTypeId: _productTypeId}, res => {
                            if (res.code === 200) {
                                skuSpecValueFun(res.data)
                            } else {
                                $('#skuSpecValue').html('')
                            }
                        }, 'get');
                    }

                    /*动态生成规格参数*/
                    function skuSpecValueFun(_data) {

                        let skuSpecNew = [], //总长的id值
                            skuSpecValueNew = [], //总长选项的id值
                            skuSpecValueNamesNew = []; //总长选项的name值)

                        $('#skuSpecValue').html('');
                        _data.forEach((item, index) => {
                            let selectHtml = '<select lay-filter="skuSpecValue' + index + '">';
                            selectHtml += '<option value="">' + item.name + '</option>';
                            item.productSpecValueList.forEach((item1, index1) => {
                                selectHtml += '<option value="' + item1.id + '" skuSpec="' + item.id + '" skuSpecValueNames="' + item1.value + '">' + item1.value + '</option>'
                            });
                            selectHtml += '</select>';
                            $('#skuSpecValue').append(selectHtml);

                            //规格参数操作
                            form.on('select(skuSpecValue' + index + ')', function (data) {
                                if (data.value) {
                                    skuSpecNew[index] = $(data.elem).find("option:selected").attr("skuSpec");
                                    skuSpecValueNamesNew[index] = $(data.elem).find("option:selected").attr("skuSpecValueNames");
                                    skuSpecValueNew[index] = data.value;
                                } else {
                                    skuSpecNew.splice(index, 1);
                                    skuSpecValueNamesNew.splice(index, 1);
                                    skuSpecValueNew.splice(index, 1);
                                }

                                $('form[lay-filter="productAddForm"] input[name="skuSpecValueNames"]').val((skuSpecValueNamesNew.filter(d => d)).join('_'));
                                productAddFormData.skuSpec = (skuSpecNew.filter(d => d)).join('_');
                                productAddFormData.skuSpecValueNew = (skuSpecValueNew.filter(d => d)).join('_');
                            });
                        });
                        form.render('select');


                    }

                    // 表单提交事件
                    form.on('submit(productAddSubmit)', function (d) {
                        d.field.exteriorSize = d.field.exteriorSize + "*" + d.field.exteriorSize1 + "*" + d.field.exteriorSize2;
                        delete d.field.exteriorSize1;
                        delete d.field.exteriorSize2;
                        d.field.skuSpec = productAddFormData.skuSpec;
                        d.field.skuSpecValueNew = productAddFormData.skuSpecValueNew;

                        layer.load(2);
                        admin.req('enterprise/product/admin/productDetailWMS/add', d.field, function (res) {
                            layer.closeAll('loading');
                            if (res.code == 200) {
                                layer.msg(res.msg, {icon: 1});
                                table.reload('productDetailTable');
                                layer.closeAll('page');
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        },'POST');
                        return false;
                    });

                }
            });
        }

        // 上传文件
        /*
        * _elem: 上传按钮的名字,
        * pathId: 显示图片容器的名字,
        * inputId: 提交文件路径元素的名字,
        * isMultiple: 是不是多文件(单文件为空或者false,多文件true)
        *
        * */
        function uploadImg(_elem, pathId, inputId, isMultiple) {
            upload.render({
                elem: '#' + _elem
                , url: config.upload_url + 'uploadFile'
                , data: {}
                , accept: 'file'
                , exts: 'jpg|png|RAR|zip|pdf|txt|doc|docx|xls|xlsx|ppt|pptx'
                , headers: {Authorization: 'Bearer ' + config.getToken()}
                , done: function (res) {
                    if (res.code == 200) {
                        layer.msg(res.msg || "上传成功", {icon: 1});
                        let imagUrl = res.data.url;
                        if (isMultiple == true) {
                            $('#' + pathId).append('<img src="' + imagUrl + '"/>');
                            $('#' + inputId).val(imagUrl);
                        } else {
                            $('#' + pathId).html('<img src="' + imagUrl + '"/>');
                            $('#' + inputId).val(imagUrl);
                        }
                    } else if (res.code == 502) {
                        return location.replace('admin/login.html');
                    } else {
                        layer.msg(res.msg || "上传失败", {icon: 2});
                    }
                }
            });
        }


        // 渲染下拉选项
        function loadSelectHtml(data, tips, htmltarget, type, formName) {
            let html = ' <option value>' + tips + '</option>';
            if (!data || data == null) {
                return;
            }
            for (let i = 0; i < data.length; i++) {
                if (type == 1) {
                    html += `<option value='${data[i].id}'>${data[i].name}</option>`;
                }
            }
            $("form[lay-filter='" + formName + "'] select[name='" + htmltarget + "']").html(html);
            form.render('select');
        }

        // 模板下载
        $('#productDetailBtnTemplate').click(function () {
            window.location.href = config.base + "enterprise/product/admin/productDetailWMS/template";
        });

        //导入excel
        $('#uploaderInput').on("change", function (e) {
            layer.load(2);
            var formData = new FormData();
            var files = e.target.files;
            let that = $(this);
            formData.append("file", files[0]);
            formData.append("name", files[0].name);//这个地方可以传递多个参数
            $.ajax({
                url: config.base + 'enterprise/product/admin/productDetailWMS/importExcel',
                data: formData,
                headers: {Authorization: 'Bearer ' + config.getToken()},
                type: "POST",
                processData: false,
                contentType: false,
                success: function (res) {
                    layer.closeAll('loading');
                    if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1});
                        layer.closeAll('page');
                        setTimeout(_ => {
                            location.reload()
                        }, 1000);
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                    that.val('');
                }
            });
        })

    });
</script>